package testcase;

import org.junit.Test;

import boundary.BoardPanel;
import control.PeciesController;
import entity.Pecies;
import junit.framework.TestCase;

public class PeciesControllerTest extends TestCase{
	public class Peciesconstub extends PeciesController{
		
	}
	Peciesconstub pcstub=new Peciesconstub();
	
	public class PeciesStub extends Pecies{

		public PeciesStub(String imgs, String iconURL, String name, int self,
				int cropW, int cropH) {
			super(imgs, iconURL, name, self, cropW, cropH);
		}
	}
	PeciesStub pstub=new PeciesStub("/images/pieces/father.PNG","/images/pieces/icon/father_big.PNG", "N",10,80, 80);
	
	public class BpStub extends BoardPanel{

		private static final long serialVersionUID = 1L;
		
	}
	BpStub bpstub=new BpStub();
	
	@Test
	public void testplayerMoveInBoard(){
		
		/**The first if-else statment*****************************************/
		/**1st if*/
		pstub.setMoveDirection(0);
		bpstub._x=0;
		bpstub._y=0;
		pcstub.playerMoveInBoard(bpstub, pstub);
		assertEquals(bpstub._x,-5);

		
		/**2nd if*/
		pstub.setMoveDirection(0);
		bpstub._x=-406;
		bpstub._y=-1;
		pstub.setX(0);
		pstub.setY(0);
		pcstub.playerMoveInBoard(bpstub, pstub);
		assertEquals(pstub.getX(),5);
		assertEquals(pstub.getY(),0);
			
		/**3rd if*/
		pstub.setMoveDirection(0);
		bpstub._x=-406;
		bpstub._y=-1;
		pstub.setX(667);
		pstub.setY(0);
		pcstub.playerMoveInBoard(bpstub, pstub);
		assertEquals(pstub.getMoveDirection(),1);
		
		/**outer-if*/
		pstub.setMoveDirection(0);
		bpstub._x=-406;
		bpstub._y=-606;
		pstub.setX(667);
		pstub.setY(0);
		pcstub.playerMoveInBoard(bpstub, pstub);
		assertEquals(pstub.getMoveDirection(),0);
		assertEquals(bpstub._x,-406);
		assertEquals(bpstub._y,-606);
		assertEquals(pstub.getX(),667);
		assertEquals(pstub.getY(),0);
		
		/**2nd if-else**************************************************************/
		/**1st if*/
		pstub.setMoveDirection(1);
		bpstub._x=-406;
		bpstub._y=0;
		pcstub.playerMoveInBoard(bpstub, pstub);
		assertEquals(bpstub._y,-5);
		
		/**2nd if*/
		pstub.setMoveDirection(1);
		bpstub._x=0;
		bpstub._y=-571;
		pstub.setX(0);
		pstub.setY(0);
		pcstub.playerMoveInBoard(bpstub, pstub);
		assertEquals(pstub.getX(),0);
		assertEquals(pstub.getY(),5);
		
		/**3rd if*/
		pstub.setMoveDirection(1);
		bpstub._x=-406;
		bpstub._y=-571;
		pstub.setX(0);
		pstub.setY(446);
		pcstub.playerMoveInBoard(bpstub, pstub);
		assertEquals(pstub.getMoveDirection(),2);
		
		//outer-if
		pstub.setMoveDirection(1);
		bpstub._x=-404;
		bpstub._y=-571;
		pstub.setX(0);
		pstub.setY(446);
		pcstub.playerMoveInBoard(bpstub, pstub);
		assertEquals(pstub.getMoveDirection(),1);
		assertEquals(bpstub._x,-404);
		assertEquals(bpstub._y,-571);
		assertEquals(pstub.getX(),0);
		assertEquals(pstub.getY(),446);
		
		/**3rd if-else***********************************************/
		/**1st if*/
		pstub.setMoveDirection(2);
		bpstub._x=-406;
		bpstub._y=-406;
		pcstub.playerMoveInBoard(bpstub, pstub);
		assertEquals(bpstub._x,-401);
		
		/**2nd if*/
		pstub.setMoveDirection(2);
		bpstub._x=0;
		bpstub._y=-404;
		pstub.setX(50);
		pstub.setY(0);
		pcstub.playerMoveInBoard(bpstub, pstub);
		assertEquals(pstub.getX(),45);
		assertEquals(pstub.getY(),0);
		
		/**3rd if*/
		pstub.setMoveDirection(2);
		bpstub._x=0;
		bpstub._y=-404;
		pstub.setX(0);
		pstub.setY(0);
		pcstub.playerMoveInBoard(bpstub, pstub);
		assertEquals(pstub.getMoveDirection(),3);
		
		/**outer-if*/
		pstub.setMoveDirection(2);
		bpstub._x=0;
		bpstub._y=606;
		pstub.setX(0);
		pstub.setY(0);
		pcstub.playerMoveInBoard(bpstub, pstub);
		assertEquals(pstub.getMoveDirection(),2);
		assertEquals(bpstub._x,0);
		assertEquals(bpstub._y,606);
		assertEquals(pstub.getX(),0);
		assertEquals(pstub.getY(),0);
		
		/**4th if-else***********************************************/
		/**1st if*/
		pstub.setMoveDirection(3);
		bpstub._x=0;
		bpstub._y=-10;
		pcstub.playerMoveInBoard(bpstub, pstub);
		assertEquals(bpstub._y,-5);
		
		/**2nd if*/
		pstub.setMoveDirection(2);
		bpstub._x=1;
		bpstub._y=1;
		pstub.setX(0);
		pstub.setY(45);
		pcstub.playerMoveInBoard(bpstub, pstub);
		assertEquals(pstub.getX(),0);
		assertEquals(pstub.getY(),40);
		
		/**3rd if*/
		pstub.setMoveDirection(2);
		bpstub._x=1;
		bpstub._y=1;
		pstub.setX(0);
		pstub.setY(0);
		pcstub.playerMoveInBoard(bpstub, pstub);
		assertEquals(pstub.getMoveDirection(),0);
		
		/**outer-if*/
		pstub.setMoveDirection(3);
		bpstub._x=1;
		bpstub._y=-1;
		pstub.setX(0);
		pstub.setY(0);
		pcstub.playerMoveInBoard(bpstub, pstub);
		assertEquals(pstub.getMoveDirection(),3);
		assertEquals(bpstub._x,1);
		assertEquals(bpstub._y,-1);
		assertEquals(pstub.getX(),0);
		assertEquals(pstub.getY(),0);
		
		
	}


}
